package app.service;


import app.BaseService;
import app.dao.RoleDao;
import app.dao.UserDao;
import app.entity.Role;
import app.entity.User;
import io.jooby.annotation.Transactional;
import jakarta.inject.Singleton;

@Singleton
public class UserService extends BaseService {

    public void saveUserAndRole() {
        var index = 1;
        //保存用户1
        User user = new User();
        user.setName("walden" + index);
        user.setAge(40 + index);
        user.setMobile("18001231559");
        user.setRemark("remark" + index);
        use(UserDao.class).insert(user);
        //int txn=1/0;
        //保存角色1
        Role role = new Role();
        role.setName("角色" + index);
        role.setCode("role" + index);
        role.setRemark("remark" + index);
        use(RoleDao.class).insert(role);
    }
}
